package com.lixh.virtual.ui.appList;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.lixh.base.BaseActivity;
import com.lixh.view.LoadView;
import com.lixh.view.UToolBar;
import com.lixh.virtual.IExtra;
import com.lixh.virtual.R;
import com.lixh.virtual.ui.appList.adapter.AppPagerAdapter;
import com.lixh.virtual.ui.appList.fragment.ListAppFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * @author Lody
 */
public class ListAppActivity extends BaseActivity {


    @BindView(R.id.clone_app_view_pager)
    ViewPager mViewPager;
    TabLayout tabLayout;
    private AppPagerAdapter appPagerAdapter;
    List<Fragment> list_fragment = new ArrayList<>();
    List<String> titles = new ArrayList<String>() {
        {
            add("克隆APP");
            add("Apps IN 内部存储");
        }
    };

    @Override
    public void init(Bundle savedInstanceState) {
        super.init(savedInstanceState);
        list_fragment.add(ListAppFragment.newInstance(IExtra.APP_CLONE_INSTANCE));
        list_fragment.add(ListAppFragment.newInstance(IExtra.APP_CLONE_STORAGE));
        setAdapter(list_fragment, titles);
    }

    public void setAdapter(List<Fragment> list_fragment, List<String> titles) {
        appPagerAdapter = new AppPagerAdapter(getSupportFragmentManager(), list_fragment, titles);
        mViewPager.setAdapter(appPagerAdapter);
        tabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    public void initLoad(LoadView.Builder builder) {
        super.initLoad(builder);
    }

    @Override
    public void initTitle(UToolBar toolBar) {
        toolBar.setCustomView(R.layout.tablayout);
        tabLayout = toolBar.findViewById(R.id.tabLayout);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_clone_app;
    }

}
